﻿using System;
using System.Data;
using System.Text;
using System.Data.OleDb;
using Maticsoft.DBUtility;//Please add references
namespace KF.DHL.DAL
{
    /// <summary>
    /// 数据访问类:Orders
    /// </summary>
    public partial class OrdersDAL
    {
        public OrdersDAL()
        { }
        #region  Method

        #region 判断运单号、转单号是否存在相关功能
        /// <summary>
        /// 判断运单号和转单号是不是已经存在
        /// </summary>
        /// <param name="orderNumber"></param>
        /// <param name="orderNumberRef"></param>
        /// <returns></returns>
        public bool IsExist(string orderNumber, string orderNumberRef)
        {
            string sqlQuery = "select count(*) from orders where orderNumber = @OrderNumber";

            if (!string.IsNullOrEmpty(orderNumberRef))
                sqlQuery += " or orderNumberRef = @orderNumberRef";

            OleDbParameter[] parameters = { new OleDbParameter("@OrderNumber", OleDbType.VarChar), new OleDbParameter("@orderNumberRef", OleDbType.VarChar) };
            parameters[0].Value = orderNumber;
            parameters[1].Value = orderNumberRef;
            int rows = Convert.ToInt32(DbHelperOleDb.GetSingle(sqlQuery, parameters));
            if (rows == 0)
                return false;
            else
                return true;
        }

        /// <summary>
        /// 判断是否已经有转单号存在的数据
        /// </summary>
        /// <param name="orderID"></param>
        /// <param name="orderNumber"></param>
        /// <returns></returns>
        public bool IsExistOrderNumber(int orderID, string orderNumber)
        {
            string sqlQuery = "select count(*) from orders where orderNumber = @OrderNumber AND ID <> @ID";

            OleDbParameter[] parameters = { new OleDbParameter("@OrderNumber", OleDbType.VarChar), new OleDbParameter("@ID", OleDbType.Integer) };
            parameters[0].Value = orderNumber;
            parameters[1].Value = orderID;
            int rows = Convert.ToInt32(DbHelperOleDb.GetSingle(sqlQuery, parameters));
            if (rows == 0)
                return false;
            else
                return true;
        }

        /// <summary>
        /// 判断是否已经有运单号存在的数据
        /// </summary>
        /// <param name="orderID"></param>
        /// <param name="orderNumber"></param>
        /// <returns></returns>
        public bool IsExistOrderNumberRef(int orderID, string orderNumberRef)
        {
            string sqlQuery = "select count(*) from orders where OrderNumberRef = @OrderNumberRef AND ID <> @ID";

            OleDbParameter[] parameters = { new OleDbParameter("@OrderNumberRef", OleDbType.VarChar), new OleDbParameter("@ID", OleDbType.Integer) };
            parameters[0].Value = orderNumberRef;
            parameters[1].Value = orderID;
            int rows = Convert.ToInt32(DbHelperOleDb.GetSingle(sqlQuery, parameters));
            if (rows == 0)
                return false;
            else
                return true;
        }

        #endregion

        #region 订单批次信息录入功能
        public bool EditOrderBatchInfo(string[] orderNumbers, string batchInfo, string flightInfo, DateTime flihtTime)
        {
            string sqlQuery = "Update Orders Set BatchInfo = @BatchInfo , FlightInfo = @FlightInfo, FlightTime = @FlightTime Where OrderNumber in ({0})";
            StringBuilder orderNumberSB = new StringBuilder();
            foreach (string temp in orderNumbers)
            {
                orderNumberSB.Append("'" + temp + "',");
            }

            sqlQuery = string.Format(sqlQuery, orderNumberSB.ToString().TrimEnd(','));

            OleDbParameter[] parameters = { new OleDbParameter("@BatchInfo", OleDbType.VarChar), new OleDbParameter("@FlightInfo", OleDbType.VarChar), new OleDbParameter("@FlightTime", OleDbType.Date) };
            parameters[0].Value = batchInfo;
            parameters[1].Value = flightInfo;
            parameters[2].Value = flihtTime;
            int rows = Convert.ToInt32(DbHelperOleDb.ExecuteSql(sqlQuery, parameters));
            if (rows > 0)
                return true;
            else
                return false;
        }

        #endregion

        #region 发运订单功能
        public bool ShippingOrders(string[] orderNumbers)
        {
            string sqlQuery = "Update orders set [Status] = 99 Where OrderNumber in ({0})";
            StringBuilder orderNumberSB = new StringBuilder();
            foreach (string temp in orderNumbers)
            {
                orderNumberSB.Append("'" + temp + "',");
            }

            sqlQuery = string.Format(sqlQuery, orderNumberSB.ToString().TrimEnd(','));

            int rows = Convert.ToInt32(DbHelperOleDb.ExecuteSql(sqlQuery));
            if (rows > 0)
                return true;
            else
                return false;
        }
        #endregion

        #region 自动生成的代码

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(KF.DHLModel.Orders model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();
            if (model.OrderNumber != null)
            {
                strSql1.Append("OrderNumber,");
                strSql2.Append("'" + model.OrderNumber + "',");
            }
            if (model.OrderNumberRef != null)
            {
                strSql1.Append("OrderNumberRef,");
                strSql2.Append("'" + model.OrderNumberRef + "',");
            }
            if (model.CountryEn != null)
            {
                strSql1.Append("CountryEn,");
                strSql2.Append("'" + model.CountryEn + "',");
            }
            if (model.CountryCN != null)
            {
                strSql1.Append("CountryCN,");
                strSql2.Append("'" + model.CountryCN + "',");
            }
            if (model.CountryCode != null)
            {
                strSql1.Append("CountryCode,");
                strSql2.Append("'" + model.CountryCode + "',");
            }
            if (model.BillingWeight != null)
            {
                strSql1.Append("BillingWeight,");
                strSql2.Append("" + model.BillingWeight + ",");
            }
            if (model.VolumeWeight != null)
            {
                strSql1.Append("VolumeWeight,");
                strSql2.Append("" + model.VolumeWeight + ",");
            }
            if (model.RealWeight != null)
            {
                strSql1.Append("RealWeight,");
                strSql2.Append("" + model.RealWeight + ",");
            }
            if (model.PriceType != null)
            {
                strSql1.Append("PriceType,");
                strSql2.Append("" + model.PriceType + ",");
            }
            if (model.ItemType != null)
            {
                strSql1.Append("[ItemType],");
                strSql2.Append("" + model.ItemType + ",");
            }
            if (model.Zone != null)
            {
                strSql1.Append("[Zone],");
                strSql2.Append("" + model.Zone + ",");
            }
            if (model.Price != null)
            {
                strSql1.Append("Price,");
                strSql2.Append("" + model.Price + ",");
            }
            if (model.AddWho != null)
            {
                strSql1.Append("AddWho,");
                strSql2.Append("'" + model.AddWho + "',");
            }
            if (model.AddTime != null)
            {
                strSql1.Append("AddTime,");
                strSql2.Append("'" + model.AddTime + "',");
            }
            if (model.EditWho != null)
            {
                strSql1.Append("EditWho,");
                strSql2.Append("'" + model.EditWho + "',");
            }
            if (model.EditTime != null)
            {
                strSql1.Append("EditTime,");
                strSql2.Append("'" + model.EditTime + "',");
            }
            if (model.Status != null)
            {
                strSql1.Append("[Status],");
                strSql2.Append("" + model.Status + ",");
            }
            if (model.Cost != null)
            {
                strSql1.Append("Cost,");
                strSql2.Append("" + model.Cost + ",");
            }
            if (model.SendTime != null)
            {
                strSql1.Append("SendTime,");
                strSql2.Append("'" + model.SendTime + "',");
            }
            if (model.SendWho != null)
            {
                strSql1.Append("SendWho,");
                strSql2.Append("'" + model.SendWho + "',");
            }
            if (model.Notes != null)
            {
                strSql1.Append("[Notes],");
                strSql2.Append("'" + model.Notes + "',");
            }
            if (model.CustomerCode != null)
            {
                strSql1.Append("CustomerCode,");
                strSql2.Append("'" + model.CustomerCode + "',");
            }
            if (model.BillingPrice != null)
            {
                strSql1.Append("BillingPrice,");
                strSql2.Append("" + model.BillingPrice + ",");
            }
            if (model.ChannelCode != null)
            {
                strSql1.Append("ChannelCode,");
                strSql2.Append("'" + model.ChannelCode + "',");
            }
            if (model.Address != null)
            {
                strSql1.Append("[Address],");
                strSql2.Append("'" + model.Address + "',");
            }
            if (model.Pieces != null)
            {
                strSql1.Append("Pieces,");
                strSql2.Append("" + model.Pieces + ",");
            }
            if (model.BillWho != null)
            {
                strSql1.Append("BillWho,");
                strSql2.Append("'" + model.BillWho + "',");
            }
            if (model.BillTime != null)
            {
                strSql1.Append("BillTime,");
                strSql2.Append("'" + model.BillTime + "',");
            }
            if (model.OrderTime != null)
            {
                strSql1.Append("OrderTime,");
                strSql2.Append("'" + model.OrderTime + "',");
            }

            if (model.BatchInfo != null)
            {
                strSql1.Append("BatchInfo,");
                strSql2.Append("'" + model.BatchInfo + "',");
            }
            if (model.FlightInfo != null)
            {
                strSql1.Append("FlightInfo,");
                strSql2.Append("'" + model.FlightInfo + "',");
            }
            if (model.FlightTime != null)
            {
                strSql1.Append("FlightTime,");
                strSql2.Append("'" + model.FlightTime + "',");
            }
            if (model.ShippingUser != null)
            {
                strSql1.Append("ShippingUser,");
                strSql2.Append("'" + model.ShippingUser + "',");
            }
            if (model.ShippingTime != null)
            {
                strSql1.Append("OrderTime,");
                strSql2.Append("'" + model.ShippingTime + "',");
            }
            strSql.Append("insert into Orders(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(KF.DHLModel.Orders model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update Orders set ");
            if (model.OrderNumber != null)
            {
                strSql.Append("OrderNumber='" + model.OrderNumber + "',");
            }
            else
            {
                strSql.Append("OrderNumber= null ,");
            }
            if (model.OrderNumberRef != null)
            {
                strSql.Append("OrderNumberRef='" + model.OrderNumberRef + "',");
            }
            else
            {
                strSql.Append("OrderNumberRef= null ,");
            }
            if (model.CountryEn != null)
            {
                strSql.Append("CountryEn='" + model.CountryEn + "',");
            }
            else
            {
                strSql.Append("CountryEn= null ,");
            }
            if (model.CountryCN != null)
            {
                strSql.Append("CountryCN='" + model.CountryCN + "',");
            }
            else
            {
                strSql.Append("CountryCN= null ,");
            }
            if (model.CountryCode != null)
            {
                strSql.Append("CountryCode='" + model.CountryCode + "',");
            }
            else
            {
                strSql.Append("CountryCode= null ,");
            }
            if (model.BillingWeight != null)
            {
                strSql.Append("BillingWeight=" + model.BillingWeight + ",");
            }
            else
            {
                strSql.Append("BillingWeight= null ,");
            }
            if (model.VolumeWeight != null)
            {
                strSql.Append("VolumeWeight=" + model.VolumeWeight + ",");
            }
            else
            {
                strSql.Append("VolumeWeight= null ,");
            }
            if (model.RealWeight != null)
            {
                strSql.Append("RealWeight=" + model.RealWeight + ",");
            }
            else
            {
                strSql.Append("RealWeight= null ,");
            }
            if (model.PriceType != null)
            {
                strSql.Append("PriceType=" + model.PriceType + ",");
            }
            else
            {
                strSql.Append("PriceType= null ,");
            }
            if (model.ItemType != null)
            {
                strSql.Append("ItemType=" + model.ItemType + ",");
            }
            else
            {
                strSql.Append("ItemType= null ,");
            }
            if (model.Zone != null)
            {
                strSql.Append("[Zone]=" + model.Zone + ",");
            }
            else
            {
                strSql.Append("[Zone]= null ,");
            }
            if (model.Price != null)
            {
                strSql.Append("Price=" + model.Price + ",");
            }
            else
            {
                strSql.Append("Price= null ,");
            }
            if (model.AddWho != null)
            {
                strSql.Append("AddWho='" + model.AddWho + "',");
            }
            else
            {
                strSql.Append("AddWho= null ,");
            }
            if (model.AddTime != null)
            {
                strSql.Append("AddTime='" + model.AddTime + "',");
            }
            else
            {
                strSql.Append("AddTime= null ,");
            }
            if (model.EditWho != null)
            {
                strSql.Append("EditWho='" + model.EditWho + "',");
            }
            else
            {
                strSql.Append("EditWho= null ,");
            }
            if (model.EditTime != null)
            {
                strSql.Append("EditTime='" + model.EditTime + "',");
            }
            else
            {
                strSql.Append("EditTime= null ,");
            }
            if (model.Status != null)
            {
                strSql.Append("[Status]=" + model.Status + ",");
            }
            else
            {
                strSql.Append("[Status]= null ,");
            }
            if (model.Cost != null)
            {
                strSql.Append("Cost=" + model.Cost + ",");
            }
            else
            {
                strSql.Append("Cost= null ,");
            }
            if (model.SendTime != null)
            {
                strSql.Append("SendTime='" + model.SendTime + "',");
            }
            else
            {
                strSql.Append("SendTime= null ,");
            }
            if (model.SendWho != null)
            {
                strSql.Append("SendWho='" + model.SendWho + "',");
            }
            else
            {
                strSql.Append("SendWho= null ,");
            }
            if (model.Notes != null)
            {
                strSql.Append("Notes='" + model.Notes + "',");
            }
            else
            {
                strSql.Append("Notes= null ,");
            }
            if (model.CustomerCode != null)
            {
                strSql.Append("CustomerCode='" + model.CustomerCode + "',");
            }
            else
            {
                strSql.Append("CustomerCode= null ,");
            }
            if (model.BillingPrice != null)
            {
                strSql.Append("BillingPrice=" + model.BillingPrice + ",");
            }
            else
            {
                strSql.Append("BillingPrice= null ,");
            }
            if (model.ChannelCode != null)
            {
                strSql.Append("ChannelCode='" + model.ChannelCode + "',");
            }
            else
            {
                strSql.Append("ChannelCode= null ,");
            }
            if (model.Address != null)
            {
                strSql.Append("Address='" + model.Address + "',");
            }
            else
            {
                strSql.Append("Address= null ,");
            }
            if (model.Pieces != null)
            {
                strSql.Append("Pieces=" + model.Pieces + ",");
            }
            else
            {
                strSql.Append("Pieces= null ,");
            }
            if (model.BillWho != null)
            {
                strSql.Append("BillWho='" + model.BillWho + "',");
            }
            else
            {
                strSql.Append("BillWho= null ,");
            }
            if (model.BillTime != null)
            {
                strSql.Append("BillTime='" + model.BillTime + "',");
            }
            else
            {
                strSql.Append("BillTime= null ,");
            }
            if (model.OrderTime != null)
            {
                strSql.Append("OrderTime='" + model.OrderTime + "',");
            }
            else
            {
                strSql.Append("OrderTime= null ,");
            }

            if (model.BatchInfo != null)
            {
                strSql.Append("BatchInfo='" + model.BatchInfo + "',");
            }
            else
            {
                strSql.Append("BatchInfo= null ,");
            }
            if (model.FlightInfo != null)
            {
                strSql.Append("FlightInfo='" + model.FlightInfo + "',");
            }
            else
            {
                strSql.Append("FlightInfo= null ,");
            }
            if (model.FlightTime != null)
            {
                strSql.Append("FlightTime='" + model.FlightTime + "',");
            }
            else
            {
                strSql.Append("FlightTime= null ,");
            }
            if (model.ShippingUser != null)
            {
                strSql.Append("ShippingUser='" + model.ShippingUser + "',");
            }
            else
            {
                strSql.Append("ShippingUser= null ,");
            }
            if (model.ShippingTime != null)
            {
                strSql.Append("ShippingTime='" + model.ShippingTime + "',");
            }
            else
            {
                strSql.Append("ShippingTime= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where ID=" + model.ID + "");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Orders ");
            strSql.Append(" where ID=" + ID + "");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }		/// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from Orders ");
            strSql.Append(" where ID in (" + IDlist + ")  ");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KF.DHLModel.Orders GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  ");
            strSql.Append(" ID,OrderNumber,OrderNumberRef,CountryEn,CountryCN,CountryCode,BillingWeight,VolumeWeight,RealWeight,PriceType,ItemType,Zone,Price,AddWho,AddTime,EditWho,EditTime,Status,Cost,SendTime,SendWho,Notes,CustomerCode,BillingPrice,ChannelCode,Address,Pieces,BillWho,BillTime,OrderTime ");
            strSql.Append(" from Orders ");
            strSql.Append(" where ID=" + ID + "");
            KF.DHLModel.Orders model = new KF.DHLModel.Orders();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderNumber"] != null && ds.Tables[0].Rows[0]["OrderNumber"].ToString() != "")
                {
                    model.OrderNumber = ds.Tables[0].Rows[0]["OrderNumber"].ToString();
                }
                if (ds.Tables[0].Rows[0]["OrderNumberRef"] != null && ds.Tables[0].Rows[0]["OrderNumberRef"].ToString() != "")
                {
                    model.OrderNumberRef = ds.Tables[0].Rows[0]["OrderNumberRef"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CountryEn"] != null && ds.Tables[0].Rows[0]["CountryEn"].ToString() != "")
                {
                    model.CountryEn = ds.Tables[0].Rows[0]["CountryEn"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CountryCN"] != null && ds.Tables[0].Rows[0]["CountryCN"].ToString() != "")
                {
                    model.CountryCN = ds.Tables[0].Rows[0]["CountryCN"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CountryCode"] != null && ds.Tables[0].Rows[0]["CountryCode"].ToString() != "")
                {
                    model.CountryCode = ds.Tables[0].Rows[0]["CountryCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BillingWeight"] != null && ds.Tables[0].Rows[0]["BillingWeight"].ToString() != "")
                {
                    //model.BillingWeight=ds.Tables[0].Rows[0]["BillingWeight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["VolumeWeight"] != null && ds.Tables[0].Rows[0]["VolumeWeight"].ToString() != "")
                {
                    //model.VolumeWeight=ds.Tables[0].Rows[0]["VolumeWeight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RealWeight"] != null && ds.Tables[0].Rows[0]["RealWeight"].ToString() != "")
                {
                    //model.RealWeight=ds.Tables[0].Rows[0]["RealWeight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PriceType"] != null && ds.Tables[0].Rows[0]["PriceType"].ToString() != "")
                {
                    model.PriceType = int.Parse(ds.Tables[0].Rows[0]["PriceType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ItemType"] != null && ds.Tables[0].Rows[0]["ItemType"].ToString() != "")
                {
                    model.ItemType = int.Parse(ds.Tables[0].Rows[0]["ItemType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Zone"] != null && ds.Tables[0].Rows[0]["Zone"].ToString() != "")
                {
                    model.Zone = int.Parse(ds.Tables[0].Rows[0]["Zone"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Price"] != null && ds.Tables[0].Rows[0]["Price"].ToString() != "")
                {
                    //model.Price=ds.Tables[0].Rows[0]["Price"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AddWho"] != null && ds.Tables[0].Rows[0]["AddWho"].ToString() != "")
                {
                    model.AddWho = ds.Tables[0].Rows[0]["AddWho"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AddTime"] != null && ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EditWho"] != null && ds.Tables[0].Rows[0]["EditWho"].ToString() != "")
                {
                    model.EditWho = ds.Tables[0].Rows[0]["EditWho"].ToString();
                }
                if (ds.Tables[0].Rows[0]["EditTime"] != null && ds.Tables[0].Rows[0]["EditTime"].ToString() != "")
                {
                    model.EditTime = DateTime.Parse(ds.Tables[0].Rows[0]["EditTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"] != null && ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cost"] != null && ds.Tables[0].Rows[0]["Cost"].ToString() != "")
                {
                    //model.Cost=ds.Tables[0].Rows[0]["Cost"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SendTime"] != null && ds.Tables[0].Rows[0]["SendTime"].ToString() != "")
                {
                    model.SendTime = DateTime.Parse(ds.Tables[0].Rows[0]["SendTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SendWho"] != null && ds.Tables[0].Rows[0]["SendWho"].ToString() != "")
                {
                    model.SendWho = ds.Tables[0].Rows[0]["SendWho"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Notes"] != null && ds.Tables[0].Rows[0]["Notes"].ToString() != "")
                {
                    model.Notes = ds.Tables[0].Rows[0]["Notes"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CustomerCode"] != null && ds.Tables[0].Rows[0]["CustomerCode"].ToString() != "")
                {
                    model.CustomerCode = ds.Tables[0].Rows[0]["CustomerCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BillingPrice"] != null && ds.Tables[0].Rows[0]["BillingPrice"].ToString() != "")
                {
                    //model.BillingPrice=ds.Tables[0].Rows[0]["BillingPrice"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ChannelCode"] != null && ds.Tables[0].Rows[0]["ChannelCode"].ToString() != "")
                {
                    model.ChannelCode = ds.Tables[0].Rows[0]["ChannelCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Address"] != null && ds.Tables[0].Rows[0]["Address"].ToString() != "")
                {
                    model.Address = ds.Tables[0].Rows[0]["Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Pieces"] != null && ds.Tables[0].Rows[0]["Pieces"].ToString() != "")
                {
                    model.Pieces = int.Parse(ds.Tables[0].Rows[0]["Pieces"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BillWho"] != null && ds.Tables[0].Rows[0]["BillWho"].ToString() != "")
                {
                    model.BillWho = ds.Tables[0].Rows[0]["BillWho"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BillTime"] != null && ds.Tables[0].Rows[0]["BillTime"].ToString() != "")
                {
                    model.BillTime = DateTime.Parse(ds.Tables[0].Rows[0]["BillTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderTime"] != null && ds.Tables[0].Rows[0]["OrderTime"].ToString() != "")
                {
                    model.OrderTime = DateTime.Parse(ds.Tables[0].Rows[0]["OrderTime"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM Orders ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperOleDb.Query(strSql.ToString());
        }

        /*
        */
        #endregion
        #endregion  Method
        
    }
}

